package Elementos;

public class Constante implements EnRango{
	private int valor;
	private boolean enrango=true;;
	
	public Constante(String v) {
		int cte=0;
		try{ cte= Integer.parseInt(v); }
		catch (NumberFormatException e) { this.enrango= false; }
		this.valor=cte;
	}
	
	public boolean estaEnRango (){
		return this.enrango;
	}
	
	public void setValor(int v){
		this.valor=v;
	}
	
	public int getValor(){
		return this.valor;
	}
	
	@Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Constante other = (Constante) obj;
        if (this.getValor()!=other.getValor()) {
            return false;
        }
        return true;
    }
	
	@Override
    public String toString(){
        return new Integer(this.valor).toString();
    }
	
	 public static void main(String[] args) {
	    Constante h= new Constante("21");
	    Constante ee= new Constante("212");
	    System.out.println(h.equals(ee));
	 }

}
